//
//  UISearchBar+Extension.swift
//  Library_y
//
//  Created by JC on 2023/6/6.
//

import UIKit
import Foundation
import SwifterSwift

public extension UISearchBar {

    /// 设置 placeholder
    ///
    /// - parameter placeholder: placeholder
    /// - parameter font:        placeholder 的字体
    /// - parameter color:       placeholder 的颜色
    func setPlaceholder(placeholder: String, withFont font: UIFont, andColor color: UIColor) {
        self.textField?.setPlaceholder(placeholder: placeholder, withFont: font, andColor: color)
    }

    /// 设置 placeholder
    ///
    /// - parameter placeholder: placeholder
    /// - parameter font:        placeholder 的字体
    func setPlaceholder(placeholder: String, withFont font: UIFont) {
        self.textField?.setPlaceholder(placeholder: placeholder, withFont: font)
    }

    /// 设置 placeholder
    ///
    /// - parameter placeholder: placeholder
    /// - parameter color:       placeholder 的颜色
    func setPlaceholder(placeholder: String, withColor color: UIColor) {
        self.textField?.setPlaceholder(placeholder: placeholder, withColor: color)
    }

}

public extension UISearchBar {

    func setBackgroundColor(color: UIColor) {
        backgroundImage = UIImage()
        backgroundColor = color
    }
}
